package com.wang.wx.utils;

import jodd.util.StringUtil;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.Random;

public class DataGenerator {
    public static void main(String[] args) {
        String[] names = {
            "Example User One", "Example User Two", "Example User Three", "Example User Four", "Example User Five",
            "Example User Six", "Example User Seven", "Example User Eight", "Example User Nine", "Example User Ten"
        };
        String[] screenNames = {
            "exuserone", "exusertwo", "exuserthree", "exuserfour", "exuserfive",
            "exusersix", "exuserseven", "exusereight", "exusernine", "exuserten"
        };
        Random random = new Random();
        SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy", Locale.ENGLISH);
        
        for (int i = 1; i <= 10000; i++) {
            String email = generateRandomEmail();
            String name = names[i % names.length];
            String screenName = screenNames[i % screenNames.length];
            int followers = random.nextInt(10000) + 1; // 随机生成1到10000之间的粉丝数量
            
            // 随机生成日期
            Calendar cal = Calendar.getInstance();
            cal.set(Calendar.YEAR, random.nextInt(11) + 2010); // 生成2010到2020之间的年份
            cal.set(Calendar.DAY_OF_YEAR, random.nextInt(365) + 1); // 生成该年的第几天
            Date createdAt = cal.getTime();
            String createdAtStr = dateFormat.format(createdAt);
            
            System.out.println(String.format("Email: %s - Name: %s - ScreenName: %s - Followers: %d - Created At: %s",
                    email, name, screenName, followers, createdAtStr));
        }
    }

    public static String generateRandomEmail() {
        // 随机用户名长度
        int usernameLength = new Random().nextInt(10) + 5; // 生成5到14之间的随机数
        StringBuilder username = new StringBuilder();

        // 生成随机用户名
        for (int i = 0; i < usernameLength; i++) {
            char randomChar = (char) ('a' + new Random().nextInt(26));
            username.append(randomChar);
        }

        // 随机选择一个域名
        String[] domains = {"example.com", "gmail.com", "hotmail.com", "yahoo.com"};
        String domain = domains[new Random().nextInt(domains.length)];

        // 拼接完整的邮箱地址
        return username.toString() + "@" + domain;
    }
}
